<template>
	<view class="Privacy">
		<view class="set-tw">
			<view class="set-t">
				<text>开启地理位置</text>
				<u-switch v-model="checked" size="40" active-color="#00c6c2" inactive-color="#eee" @change="add_chanage"></u-switch>
			</view>
			<view class="set-t">
				<text>允许访问相册</text>
				<u-switch v-model="checke" size="40" active-color="#00c6c2" inactive-color="#eee"></u-switch>
			</view>
			<view class="set-t">
				<text>允许访问相机</text>
				<u-switch v-model="check" size="40" active-color="#00c6c2" inactive-color="#eee"></u-switch>
			</view>
			<view class="set-t">
				<text>允许访问麦克风</text>
				<u-switch v-model="chec" size="40" active-color="#00c6c2" inactive-color="#eee"></u-switch>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				checked:true,
				checke:false,
				check:false,
				chec:false,
			}
		},
		methods:{
			//手动开启地址授权
			add_chanage(e){
				// console.log(e)
				let that = this
				if(e==true){
					uni.authorize({
						scope:'scope.address',
						success(res) {
							// that.checked = true
							console.log(res)
							
						}
					})
				}
			}
		},
		mounted() {
			this.$nextTick(function(){
				uni.getSetting({
					success: (res) => {
						console.log(res.authSetting)
						//判断是否开启了地理位置授权
						if(res.authSetting['scope.address']==true){
							this.checked == true
						}else{
							this.checked == false
						}
					
					}
				})
			})
			
			// uni.openSetting({
			//   success(res) {
			//     console.log(res.authSetting)
			//   }
			// });
		}
	}
</script>

<style lang="scss">
	.Privacy{
		padding: 0 20rpx;
	}
	.set-tw{
		
		background-color: #fff;
		
		.set-t{
			padding: 25rpx 0;
			border-bottom: 1rpx solid #F1F1F1;
			background-color: #fff;
			display: flex;
			align-items: center;
			justify-content: space-between;
			
			text{
				font-size: 30rpx;
				color: #333333;
			}
			
			image{
				width: 10rpx;
				height: 20rpx;
			}
		}
	}
</style>
